﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;
using BLL;
namespace UI.ModMini
{
    public partial class HostelEmpList : System.Web.UI.Page
    {
        MiniBiz miniBiz = new MiniBiz();
        DefDicBiz defDicBiz = new DefDicBiz();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                defDicBiz.InitDropDownList(miniBiz.GetHostelLists(), ddlHostel);
                btnAdd.Attributes.Add("onclick", "javascript:ShowLink('HostelEmpAdd.aspx',800,550);");
                btnAddFei.Attributes.Add("onclick", "javascript:ShowLink('HostelEmpFee.aspx',800,550);");
               // BondData("", "","Y");

            }
        }
        private void BondData(string serWord, string hostelCode, string statu)
        {
            DataTable dt = miniBiz.GetHostelEmpLists(serWord, hostelCode, statu);

            if (dt.Rows.Count > 0)
            {
                lbAmount.Text = "合计:    " + dt.Rows.Count;
            }
            else
            {
                lbAmount.Text = "";
            }
            gvList.DataSource = dt;
            gvList.DataBind();

        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string serWord = txtSerWord.Text.Trim();
            string hostelCode = ddlHostel.SelectedValue;
            BondData(serWord, hostelCode,"Y");
        }
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            string serWord = txtSerWord.Text.Trim();
            string hostelCode = ddlHostel.SelectedValue;
            ExcelUtility.ExportDsToXls(this, miniBiz.GetHostelEmpLists(serWord,"", "Y"), "HostelList.xls");
        }
        protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F3F8F8'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            }
        }
    }
}